package controllers

import (
	"github.com/astaxie/beego"

	"fmt"
)

type MainController struct {
	beego.Controller
}
/*
func (c *MainController) Get() {
	c.Data["Website"] = "beego.me"
	c.Data["Email"] = "astaxie@gmail.com"
	c.Data["name"]="zhangsan"
	c.Data["isNan"]=true
	c.Data["user"]=user{1,"wangwu",18}
	 nums:=[]int{1,2,3,4,5,6,7,8}
	c.Data["numbers"]=nums
	c.Data["ccccccc"]="gays!"
	c.Data["html"]="<div>hhhhhhaaa</div>"
	c.Data["pipe"]="<div>pipe</div>"
	c.TplNames = "index.tpl"
}*/


func (this *MainController) Get() {
	fmt.Println("MainController Get" )

	this.Data["isHome"]=true
	fmt.Println( this.Ctx.GetCookie("uname"))

	if  ""!=this.Ctx.GetCookie("uname"){
		this.Data["IsLogin"]=CheckAccount(this.Ctx,nil)
	}
	this.TplNames = "home.html"
}


type user struct {
	Id int
	Name string
	Age int
}


func (c*MainController) Post(){
	c.Ctx.WriteString(beego.AppConfig.String("appname")+"\n"+beego.AppConfig.String("httpport") +"\n"+beego.RunMode)
	//日志级别
	beego.SetLevel(beego.LevelError)

	beego.Trace("trace ")
	beego.Info("Info ")
}